#include <iostream>
#include <vector>

using namespace std;

class Solution
{
public:
    int recursionTry(int curChind, int sumChind, int limit, int candies, vector<vector<long long>> &dp)
    {
        if (curChind == sumChind)
        {
            if (candies > limit)
            {
                return 0;
            }
            return 1;
        }
        if (dp[candies][curChind] != -1)
        {
            return dp[candies][curChind];
        }
        long long ans = 0;
        for (int i = 0; i <= limit; i++)
        {
            // 剪支
            if ((sumChind - curChind) * limit >= (candies - i) && candies >= i)
            {
                ans = (ans + recursionTry(curChind + 1, sumChind, limit, candies - i, dp));
            }
        }
        dp[candies][curChind] = ans;
        return ans;
    }
    long long distributeCandies1(int n, int limit)
    {
        vector<vector<long long>> dp(n + 1, vector<long long>(3 + 1, -1));
        return recursionTry(1, 3, limit, n, dp);
    }

};

int main()
{
    return 0;
}